import api from '@/http/index'

class Api {
    /* 获取列表 */
    static getTablesList(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/PurchaseOrders/GetGridJson', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* 新建 */
    static addTablesItem(data) {
        return new Promise((resolve, reject) => {
            api.post('/api/PurchaseOrders/SubmitForm', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* 删除 */
    static deleteItem(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/PurchaseOrders/DeleteForm', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* 根据id查询 */
    static getItemInfo(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/PurchaseOrders/GetForm', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* ======== 采购单明细 ======== */
    static getTablesListDetail(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/PurchaseOrdersDetail/GetGridJson', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* 商品自动完成 */
    static handleSearchProduct(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/Products/AutoComplete', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    static getProductNorm(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/ProductsSpec/GetGridJson', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* 新建 */
    static addTablesItemDetail(data) {
        return new Promise((resolve, reject) => {
            api.post('/api/PurchaseOrdersDetail/SubmitForm', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    /* 删除 */
    static deleteItemDetail(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/PurchaseOrdersDetail/DeleteForm', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
    //获取采购单明细
    static GetForm(data) {
        return new Promise((resolve, reject) => {
            api.get('/api/PurchaseOrdersDetail/GetFormByID', data).then((res) => {
                resolve(res);
            }).catch(err => {
                reject(err)
            })
        });
    }
}

export default Api


